<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/includes.jsp" %>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>原材料物料浏览</title>
	<!-- import css and js --> 
	<%@ include file="/common/metaInput.jsp" %>  
	<script src="${ctx}/js/jsp/comm.js" type="text/javascript"></script>
<script type="text/javascript">
var basic_Url="${ctx}/yd/basic/materials";
$(function(){
$("#inputForm").validate({			   
	onsubmit: true,
	 /*执行ajaxsubmit  */ 
    submitHandler: function(editform) {
            
        //alert(jsonInfo); 
        try{			    		
            url =  basic_Url+"/save.do";
            var api = frameElement.api;
        	var W = api.opener;
            getReturnMessage(url,"inputForm",W.searchAP);
            W.pid='${pid}';
        }catch(e){alert(e);}
    }
 }
);
if('${flag}' == 'browse'){
	$("input[type!='hidden']").attr("disabled","disabled");
	$("select").attr("disabled","disabled");//禁用SELECT标签
	$("textarea").attr("disabled","disabled");//禁用TEXTAREA标签
}
if ('${flag}' == 'edit'){
	 $("#code").attr("disabled","disabled");
	 $("select[id='placeCode']").attr("disabled","disabled");
	 $("input[id='materialTypeCode']").attr("disabled","disabled");
	 $("input[id='materialNumberCategoryCode']").attr("disabled","disabled");
	 $("select[id='supplierCode']").attr("disabled","disabled");
	 $("input[id='unit']").attr("disabled","disabled");
}
});
function submitForm(param){
    //设置ajax全局同步
	jQuery.ajaxSettings.async = false;
  	$("#submitFlag").val(param);
    $("#inputForm").submit();
 }		
 
function updateDescription(value){
	 $("#description").val($("#pname").val()+";"+value);
}
	
</script>

</head>

<body>

<form id="inputForm" action="" method="post">
<input type="hidden" id="id" name="id" value="${materials.id}"/>
<!-- 用于标识提交按钮 -->
<input type="hidden" id="submitFlag" value="" />
 <div class="pageContent" >
    <div class="panel">
         <table class="TableBlock" align="center">
          			<tr>
          				<td nowrap="nowrap">材料名称:</td>
   		                 <td>
   		                		<input type="text" id="name" name="name" class="required" style="width: 40%;"  readonly="readonly"  value="${materials.name == null ? pname : materials.name}" />
   		                 </td>
   		           </tr>
   		           <tr>
          				<c:if test="${not empty materials.code}">
   		            	<td nowrap="nowrap">材料编码:</td>
   		                 <td>
   		                		<input type="text" id="code" name="code" class="required"  style="width: 40%;" value="${materials.code}"  size="50%" />
   		                 </td>   
   		             	</c:if>    
   		           </tr>
   		           <tr>
                    	 <td nowrap="nowrap">所属类型:</td>
   		                 <td>
   		                		<input type="text" disabled="disabled"  value="${pname}" style="width: 40%;"/>
   		                		<input type="hidden" id="pid" name="pid"  value="${pid}" />
   		                		<input type="hidden" id="pname" name="pname"  value="${pname}" />
   		                 </td>
   		           </tr>
   		            <tr>
   		                 <td nowrap="nowrap">单价:</td>
   		                 <td>
   		                		<input type="text" id="price" name="price" style="width: 40%;"  value="${materials.price}" />
   		                 </td>
   		           </tr>
   		             <tr>
   		                 <td nowrap="nowrap">型号:</td>
   		                 <td>
   		                		<input type="text" id="spec" name="spec"  style="width: 40%;"  class="required" value="${materials.spec}" onkeyup="updateDescription(this.value)"/>
   		                 </td>
   		           </tr>
   		            <tr>
   		                 <td nowrap="nowrap">保质期:</td>
   		                 <td>
   		                		<input type="text" id="shelfLife" name="shelfLife"  style="width: 40%;"  value="${materials.shelfLife}" />
   		                 </td>
   		           </tr>
   		           <tr>
   		                 <td nowrap="nowrap">最高库存:</td>
   		                 <td>
   		                		<input type="text" id="highestInventory" name="highestInventory" class="required"  style="width: 40%;" value="${materials.highestInventory}" />
   		                 </td>
   		           </tr>
   		            <tr>
   		                 <td nowrap="nowrap">最低库存:</td>
   		                 <td>
   		                		<input type="text" id="minmunInventory" name="minmunInventory" class="required" style="width: 40%;"  value="${materials.minmunInventory}" />
   		                 </td>
   		           </tr>
   		            <tr>
   		                <td nowrap="nowrap">默认仓库:</td>
   		                 <td>
   		                 <select id="defaultWarehouse" name="defaultWarehouse">
   		                 	<option></option>
   		                 	<c:forEach items="${bStorageinfoDOs }" var="bd">
   		                 		<option value="${bd.name }">${bd.name }</option>
   		                 	</c:forEach>
   		                 </select>
   		                 <script type="text/javascript">
   		                 	$("#defaultWarehouse").val('${materials.defaultWarehouse}');
   		                 </script>
   		                 </td>
   		           </tr>
   		           <tr>
   		                 <td nowrap="nowrap">安全库存数量:</td>
   		                 <td>
   		                		<input type="text" id="safetyStock" name="safetyStock" style="width: 40%;"   value="${materials.safetyStock}" />
   		                 </td>
   		           </tr>
   		           <tr>
   		                 <td nowrap="nowrap">数量精度:</td>
   		                 <td>
   		                		<input type="text" id="quantitativeAccuracy" name="quantitativeAccuracy"  style="width: 40%;"  value="${materials.quantitativeAccuracy}" />
   		                 </td>
   		           </tr>
   		           <tr>
   		                 <td nowrap="nowrap">地点代码:</td>
   		                 <td>
   		                 		<select id="placeCode" name="placeCode" class="required">
   		                 		<option></option>
   		                 		<c:forEach items="${areaDOs }" var="areaDOs">
   		                 			<option value="${areaDOs.areacode }">${areaDOs.areaname }</option>
   		                 		</c:forEach>
   		                 	</select>
   		                 	<script type="text/javascript">
   		                 		//yan需求，默认选中深圳
								$("#placeCode").val("${not empty materials.placeCode ? materials.placeCode :'2'}");
							</script>
   		                 </td>
   		           </tr>
   		           <tr>
   		                 <td nowrap="nowrap">物料类型代码:</td>
   		                 <td>
   		                 <c:choose>
   		                 	<c:when test="${not empty materials.materialTypeCode}">
   		                 		<input type="hidden" id="materialTypeCode" class="required" style="width: 40%;"  name="materialTypeCode"  value="${materials.materialTypeCode}" />
   		                 		<input type="text" id="materialTypeCodeName" class="required" style="width: 40%;" readonly="readonly" name="materialTypeCodeName"  value="${materials.materialTypeCodeName}" />
   		                 	</c:when>
   		                 	<c:otherwise>
   		                 		<input type="hidden" id="materialTypeCode" class="required" style="width: 40%;"  name="materialTypeCode"  value="${wlTypeRemark.remark}" />
   		                 		<input type="text" id="materialTypeCodeName" class="required" style="width: 40%;" readonly="readonly"  name="materialTypeCodeName"  value="${wlTypeRemark.name}" />
   		                 	</c:otherwise>
   		                </c:choose>		
   		                 </td>
   		           </tr>
   		           <tr>
   		                 <td nowrap="nowrap">料号类别代码:</td>
   		                 <td>
   		                 <c:choose>
   		                 <c:when test="${not empty materials.materialTypeCode}">
   		                 		<input type="hidden" id="materialNumberCategoryCode" class="required" style="width: 40%;"  name="materialNumberCategoryCode"  value="${materials.materialNumberCategoryCode}" />
   		                 		<input type="text" id="materialNumberCategoryCodeName" class="required" style="width: 40%;" readonly="readonly"  name="materialNumberCategoryCodeName"  value="${materials.materialNumberCategoryCodeName}" />
   		                 	</c:when>
   		                 	<c:otherwise>
   		                 		<input type="hidden" id="materialNumberCategoryCode" class="required" style="width: 40%;"  name="materialNumberCategoryCode"  value="${lhTypeRemark.remark}" />
   		                 		<input type="text" id="materialNumberCategoryCodeName" class="required" style="width: 40%;" readonly="readonly"  name="materialNumberCategoryCodeName"  value="${lhTypeRemark.name}" />
   		                 	</c:otherwise>
   		                </c:choose>
   		                 </td>
   		           </tr>
   		           <tr>
   		                 <td nowrap="nowrap">供应商代码:</td>
   		                 <td>
	   		                 		<select id="supplierCode" name="supplierCode" class="required">
	   		                 		<option></option>
	   		                 		<c:forEach items="${companyDOs }" var="companyDOs">
	   		                 			<option value="${companyDOs.code }">${companyDOs.code }-${companyDOs.name }</option>
	   		                 		</c:forEach>
	   		                 	</select>
	   		                 	<script type="text/javascript">
									$("#supplierCode").val('${materials.supplierCode}');
								</script>
   		                 </td>
   		           </tr>
   		           <tr>
   		             <td>基本单位:</td>
   		             <td>
   		             <c:choose>
   		             <c:when test="${empty materials.unit }">
                 		<select id="unit" name="unit" class="required" >
	                 		<option></option>
 		                 		<c:forEach items="${unitDOs }" var="unitDOs">
 		                 			<option value="${unitDOs.unitcode }">${unitDOs.unitname }</option>
 		                 		</c:forEach>
 		                </select>
 		                <script type="text/javascript">
							$("#unit").val('${materials.unit}');
				    	</script>
				    	</c:when>
				    	<c:otherwise>
				    	<input type="text" id="unit" name="unit" readonly="readonly" style="width: 40%;" value="${materials.unit }"/>
				    	</c:otherwise>
				    	</c:choose>
   		             </td>
   		           </tr>
   		           <tr>
   		             <td>财务分类:</td>
   		             <td>
			             <select id="remark1" name="remark1" class="required" >
	                		<option></option>
		                 	<option value="包装物">包装物</option>
		                 	<option value="低值易耗品">低值易耗品</option>
		                 	<option value="辅助材料">辅助材料</option>
		                 	<option value="工程物资">工程物资</option>
		                 	<option value="直接材料">直接材料</option>
	                	</select>
	                	<c:if test="${not empty materials.remark1 }">
	                		<script type="text/javascript">
	                			$("#remark1").val('${materials.remark1}');
	                		</script>
	                	</c:if>
   		             </td>
   		           </tr>
   		           <tr>
   		             <td>是否开启批次:</td>
   		             <td>
			             <select id="remark2" name="remark2" class="required" >
	                		<option></option>
		                 	<option value="Y">是</option>
		                 	<option value="N">否</option>
	                	</select>
	                	<c:if test="${not empty materials.remark2 }">
	                		<script type="text/javascript">
	                			$("#remark2").val('${materials.remark2}');
	                		</script>
	                	</c:if>
   		             </td>
   		           </tr>
   		           <tr>
   		           <td nowrap="nowrap">描述:</td>
   		                 <td>
   		                		<input type="text" style="width: 40%;"  readonly="readonly"  id="description" name="description"  value="${materials.description}" />
   		                 </td>
   		            </tr>
   		            
   		           <tr>
   		             <td>备注:</td>
   		           	 <td><input id="remark" style="width: 40%;" name="remark" value="${materials.remark}" /></td>
   		           </tr>
                </table>               
         </div>
         <div class="formBar">
	        <ul>
		       <li><div class="button"><div class="buttonContent"><button type="button" class="print" onclick="CloseDialog()">关闭</button></div></div></li>
	        </ul>
        </div>    
    </div>
</form>
</body>
</html>
